package com.saver.view;

import java.util.Map;

import com.saver.R;
import com.saver.core.domain.Parametro;
import com.saver.core.persistence.ParametroSQLite;
import com.saver.core.util.Constantes;
import com.saver.view.adapter.ResetAutoComplete;
import com.saver.view.dialog.RefreshActivity;
import com.saver.view.splash.SplashScreen;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class TerminosCondicionesDialog extends DialogFragment implements
		ResetAutoComplete, View.OnClickListener {

	TextView textTerminos;
	
	private View view;
	private String linkTerminos = "<a href=\"http://www.mingy.org\">T&eacute;rminos de servicio</a>";
	private TerminosCondiconesListener terminosCondicionesListener;

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
        setCancelable(false);
		view = LayoutInflater.from(getActivity()).inflate(
				R.layout.dialog_terminos_condiciones, null);

		textTerminos = (TextView) view.findViewById(R.id.linkTerminos);
		textTerminos.setMovementMethod(LinkMovementMethod.getInstance());
		final AlertDialog dialog = new AlertDialog.Builder(getActivity())
				.setView(view)
				.setPositiveButton("Aceptar",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,	int which) {
								terminosCondicionesListener.onDialogPositiveClick(TerminosCondicionesDialog.this);
							}
						})
				.setNegativeButton("Rechazar",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,	int which) {
								terminosCondicionesListener.onDialogNegativeClick(TerminosCondicionesDialog.this);
							}
						})

				.create();
		dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		return dialog;
	}
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			//crea la instanacia del listener TerminosCondiconesListener para enviarlas a la actividad padre
			terminosCondicionesListener = (TerminosCondiconesListener) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ " must implement NoticeDialogListener");
		}
	}

	//Inteface para enviar eventos a la actividad padre
	public interface TerminosCondiconesListener {
		public void onDialogPositiveClick(DialogFragment dialog);
		public void onDialogNegativeClick(DialogFragment dialog);
	}

	@Override
	public void onClick(View v) {
	
	}

	@Override
	public void reset() {
		
	}

}
